<template>
    <div class="container">
        <h3>检测依据</h3>
        <el-form>


        <el-tabs v-model="activeName" type="border-card" style="margin-top:20px;" @tab-click="handleClick">
            <el-tab-pane v-if='switchHeadTab == "生产系统"' label="中药材" name="中药材">
                <el-row>
                    <el-col :span="7">
                        <el-input placeholder="请输入关键词" v-model.trim="searchName1" style="width:300px;">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch1">搜索</el-button>
                        </el-input>
                    </el-col>
<!--                    <el-button type="primary" style="float:right; margin-right: 10px" v-if="added"  @click="handleadded">新增</el-button>-->
                </el-row>
                <el-table
                    :data="tableData1"
                    border
                    style="margin-top:20px;"
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
<!--                    <el-table-column prop="checkName" sortable label="标准名称"></el-table-column>-->
                    <el-table-column prop="createTime" sortable label="添加时间"></el-table-column>
                     <el-table-column prop="breedName" sortable label="物料名称"></el-table-column>
                    <el-table-column prop="basis" sortable label="附件">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handlecheck(scope.$index, scope.row)"
                            >{{scope.row.basis}}</el-button>

                        </template>
                    </el-table-column>
                    <el-table-column prop="stateful" sortable label="状态"></el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button type="text">
                                <el-dropdown style="color: #409EFF; font-size:12px">
                                    <span class="el-dropdown-link">
                                        更多
                                    </span>
                                    <el-dropdown-menu slot="dropdown">
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                style="color:black;"
                                                v-show="disable"
                                                v-if="state == scope.row.state"
                                                @click="disabled(scope.$index, scope.row)"
                                            >禁用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                v-show="disable"
                                                v-if="state == scope.row.state?0:1"
                                                @click="start(scope.$index, scope.row)"
                                            >启用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                            type="text"
                                            style="color:red;"
                                            v-if="del"
                                            @click="handleDelete1(scope.$index, scope.row)"
                                        >删除</el-button>
                                        </el-dropdown-item>
                                    </el-dropdown-menu>
                                </el-dropdown>
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize" :current-page.sync="currentPage1"  @current-change="handleCurrentChange1" :total="total1" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "生产系统"' label="辅料" name="辅料">
                <el-row>
                    <el-col :span="7">
                        <el-input style="width:300px;" placeholder="请输入关键词" v-model.trim="searchName2">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch2">搜索</el-button>
                        </el-input>
                    </el-col>
<!--                    <el-button type="primary" style="float:right; margin-right: 10px" v-if="added"  @click="handleadded">新增</el-button>-->
                </el-row>

                <el-table
                    :data="tableData2"
                    border
                    style="margin-top:20px;"
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
<!--                  <el-table-column prop="checkName" sortable label="标准名称"></el-table-column>-->
                    <el-table-column prop="createTime" sortable label="添加时间"></el-table-column>
                  <el-table-column prop="breedName" sortable label="物料名称"></el-table-column>
                    <!-- <el-table-column prop="standard" sortable label="标准类型"></el-table-column> -->
                    <el-table-column prop="basis" sortable label="附件">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handlecheck(scope.$index, scope.row)"
                            >{{scope.row.basis}}</el-button>

                        </template>
                    </el-table-column>
                    <el-table-column prop="stateful" sortable label="状态"></el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button type="text">
                                <el-dropdown style="color: #409EFF; font-size:12px">
                                    <span class="el-dropdown-link">
                                        更多
                                    </span>
                                    <el-dropdown-menu slot="dropdown">
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                style="color:black;"
                                                v-show="disable"
                                                v-if="state == scope.row.state"
                                                @click="disabled(scope.$index, scope.row)"
                                            >禁用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                v-show="disable"
                                                v-if="state == scope.row.state?0:1"
                                                @click="start(scope.$index, scope.row)"
                                            >启用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                            type="text"
                                            style="color:red;"
                                            v-if="del"
                                            @click="handleDelete1(scope.$index, scope.row)"
                                        >删除</el-button>
                                        </el-dropdown-item>
                                    </el-dropdown-menu>
                                </el-dropdown>
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize" :current-page.sync="currentPage2"  @current-change="handleCurrentChange2" :total="total2" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "中药饮片"' label="中药饮片(半成品)" name="中药饮片(半成品)">
                <el-row>
                    <el-col :span="7">
                        <el-input style="width:300px;" placeholder="请输入关键词" v-model.trim="searchNamebcp">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearchbcp">搜索</el-button>
                        </el-input>
                    </el-col>
                </el-row>

                <el-table
                    :data="tableDatabcp"
                    border
                    style="margin-top:20px;"
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
                    <el-table-column prop="checkName" sortable label="标准名称"></el-table-column>
                    <el-table-column prop="createTime" sortable label="添加时间"></el-table-column>
                    <!--                    <el-table-column prop="standard" sortable label="标准类型"></el-table-column>-->
                    <el-table-column prop="breedName" sortable label="物料名称"></el-table-column>
                    <el-table-column prop="basis" sortable label="附件">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handlecheck(scope.$index, scope.row)"
                            >{{scope.row.basis}}</el-button>

                        </template>
                    </el-table-column>
                    <el-table-column prop="stateful" sortable label="状态"></el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button type="text">
                                <el-dropdown style="color: #409EFF; font-size:12px">
                                    <span class="el-dropdown-link">
                                        更多
                                    </span>
                                    <el-dropdown-menu slot="dropdown">
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                v-if="state == scope.row.state"
                                                style="color:black;"
                                                v-show="disable"
                                                @click="disabled(scope.$index, scope.row)"
                                            >禁用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                v-show="disable"
                                                v-if="state == scope.row.state?0:1"
                                                @click="start(scope.$index, scope.row)"
                                            >启用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                style="color:red;"
                                                v-if="del"
                                                @click="handleDelete1(scope.$index, scope.row)"
                                            >删除</el-button>
                                        </el-dropdown-item>
                                    </el-dropdown-menu>
                                </el-dropdown>
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize" :current-page.sync="currentPagebcp"  @current-change="handleCurrentChangebcp" :total="totalbcp" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "中药饮片"' label="中药饮片" name="中药饮片">
                <el-row>
                    <el-col :span="7">
                        <el-input style="width:300px;" placeholder="请输入关键词" v-model.trim="searchNamezy">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearchzy">搜索</el-button>
                        </el-input>
                    </el-col>
<!--                    <el-col :span="7">-->
<!--                        <el-form-item label="标准类型：" prop="standard">-->
<!--                            <el-select v-model="standard"  filterable placeholder="请选择" style="width: 300px;" @change="handlechange">-->
<!--                                <el-option label="国标" value="1"></el-option>-->
<!--                                <el-option label='省标' value="2"></el-option>-->
<!--                            </el-select>-->
<!--                        </el-form-item>-->
<!--                    </el-col>-->
                </el-row>

                <el-table
                    :data="tableDatazy"
                    border
                    style="margin-top:20px;"
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
                    <el-table-column prop="checkName" sortable label="标准名称"></el-table-column>
                    <el-table-column prop="createTime" sortable label="添加时间"></el-table-column>
<!--                    <el-table-column prop="standard" sortable label="标准类型"></el-table-column>-->
                    <el-table-column prop="breedName" sortable label="物料名称"></el-table-column>
                    <el-table-column prop="basis" sortable label="附件">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handlecheck(scope.$index, scope.row)"
                            >{{scope.row.basis}}</el-button>

                        </template>
                    </el-table-column>
                    <el-table-column prop="stateful" sortable label="状态"></el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button type="text">
                                <el-dropdown style="color: #409EFF; font-size:12px">
                                    <span class="el-dropdown-link">
                                        更多
                                    </span>
                                    <el-dropdown-menu slot="dropdown">
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                v-if="state == scope.row.state"
                                                style="color:black;"
                                                v-show="disable"
                                                @click="disabled(scope.$index, scope.row)"
                                            >禁用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                v-show="disable"
                                                v-if="state == scope.row.state?0:1"
                                                @click="start(scope.$index, scope.row)"
                                            >启用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                style="color:red;"
                                                v-if="del"
                                                @click="handleDelete1(scope.$index, scope.row)"
                                            >删除</el-button>
                                        </el-dropdown-item>
                                    </el-dropdown-menu>
                                </el-dropdown>
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize" :current-page.sync="currentPagezy"  @current-change="handleCurrentChangezy" :total="totalzy" style="margin-top:20px"></el-pagination>
            </el-tab-pane>

            <el-tab-pane v-if='switchHeadTab == "生产系统"' label="提取饮片" name="提取饮片">
                <el-row>
                    <el-col :span="7">
                        <el-input style="width:300px;" placeholder="请输入关键词" v-model.trim="searchName3">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch3">搜索</el-button>
                        </el-input>
                    </el-col>
					<el-col :span="7">
					   <el-form-item label="标准类型：" prop="standard">
					        <el-select v-model="standard"  filterable placeholder="请选择" style="width: 300px;" @change="handlechange">
					            <el-option label="国标" value="1"></el-option>
					            <el-option label='省标' value="2"></el-option>
					        </el-select>
					    </el-form-item>
					</el-col>
<!--                    <el-button type="primary" style="float:right; margin-right: 10px" v-if="added"  @click="handleadded">新增</el-button>-->
                </el-row>

                <el-table
                    :data="tableData3"
                    border
                    style="margin-top:20px;"
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
                 <el-table-column prop="checkName" sortable label="标准名称"></el-table-column>
                    <el-table-column prop="createTime" sortable label="添加时间"></el-table-column>
                    <el-table-column prop="standard" sortable label="标准类型"></el-table-column>
                  <el-table-column prop="breedName" sortable label="物料名称"></el-table-column>
                    <el-table-column prop="basis" sortable label="附件">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handlecheck(scope.$index, scope.row)"
                            >{{scope.row.basis}}</el-button>

                        </template>
                    </el-table-column>
                    <el-table-column prop="stateful" sortable label="状态"></el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button type="text">
                                <el-dropdown style="color: #409EFF; font-size:12px">
                                    <span class="el-dropdown-link">
                                        更多
                                    </span>
                                    <el-dropdown-menu slot="dropdown">
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                v-if="state == scope.row.state"
                                                style="color:black;"
                                                v-show="disable"
                                                @click="disabled(scope.$index, scope.row)"
                                            >禁用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                v-show="disable"
                                                v-if="state == scope.row.state?0:1"
                                                @click="start(scope.$index, scope.row)"
                                            >启用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                            type="text"
                                            style="color:red;"
                                            v-if="del"
                                            @click="handleDelete1(scope.$index, scope.row)"
                                        >删除</el-button>
                                        </el-dropdown-item>
                                    </el-dropdown-menu>
                                </el-dropdown>
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize" :current-page.sync="currentPage3"  @current-change="handleCurrentChange3" :total="total3" style="margin-top:20px"></el-pagination>
            </el-tab-pane>
			<el-tab-pane v-if='switchHeadTab == "生产系统"' label="配方颗粒(浸膏粉)" name="配方颗粒(浸膏粉)">
			    <el-row>
			        <el-col :span="7">
			            <el-input style="width:300px;" placeholder="请输入关键词" v-model.trim="searchName6">
			                <i slot="prefix" class="el-input__icon el-icon-search"></i>
			                <el-button slot="append" @click="handleSearch6">搜索</el-button>
			            </el-input>
			        </el-col>
					<el-col :span="7">
					   <el-form-item label="标准类型：" prop="standard">
					        <el-select v-model="standard"  filterable placeholder="请选择" style="width: 300px;" @change="handlechange">
					            <el-option label="国标" value="1"></el-option>
					            <el-option label='省标' value="2"></el-option>
					        </el-select>
					    </el-form-item>
					</el-col>
<!--			        <el-button type="primary" style="float:right; margin-right: 10px" v-if="added"  @click="handleadded">新增</el-button>-->
			    </el-row>

			    <el-table
			        :data="tableData6"
			        border
			        style="margin-top:20px;"
			        ref="multipleTable"
			        header-cell-class-name="table-header"
			    >
<!--			      <el-table-column prop="checkName" sortable label="标准名称"></el-table-column>-->
			        <el-table-column prop="createTime" sortable label="添加时间"></el-table-column>
                    <el-table-column prop="standard" sortable label="标准类型"></el-table-column>
            <el-table-column prop="breedName" sortable label="物料名称"></el-table-column>
			        <el-table-column prop="basis" sortable label="附件">
			            <template slot-scope="scope">
			                <el-button
			                    type="text"
			                    @click="handlecheck(scope.$index, scope.row)"
			                >{{scope.row.basis}}</el-button>

			            </template>
			        </el-table-column>
			        <el-table-column prop="stateful" sortable label="状态"></el-table-column>
			        <el-table-column label="操作" width="150" align="center">
			            <template slot-scope="scope">
			                <el-button
			                    type="text"
			                    v-if="edit"
			                    @click="handleEdit(scope.$index, scope.row)"
			                >编辑</el-button>
			                <el-button type="text">
			                    <el-dropdown style="color: #409EFF; font-size:12px">
			                        <span class="el-dropdown-link">
			                            更多
			                        </span>
			                        <el-dropdown-menu slot="dropdown">
			                            <el-dropdown-item>
			                                <el-button
			                                    type="text"
			                                    style="color:black;"
			                                    v-show="disable"
			                                    v-if="state == scope.row.state"
			                                    @click="disabled(scope.$index, scope.row)"
			                                >禁用</el-button>
			                            </el-dropdown-item>
			                            <el-dropdown-item>
			                                <el-button
			                                    type="text"
			                                    v-show="disable"
			                                    v-if="state == scope.row.state?0:1"
			                                    @click="start(scope.$index, scope.row)"
			                                >启用</el-button>
			                            </el-dropdown-item>
			                            <el-dropdown-item>
			                                <el-button
			                                type="text"
			                                style="color:red;"
			                                v-if="del"
			                                @click="handleDelete1(scope.$index, scope.row)"
			                            >删除</el-button>
			                            </el-dropdown-item>
			                        </el-dropdown-menu>
			                    </el-dropdown>
			                </el-button>
			            </template>
			        </el-table-column>
			    </el-table>
			    <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize" :current-page.sync="currentPage6"  @current-change="handleCurrentChange6" :total="total6" style="margin-top:20px"></el-pagination>
			</el-tab-pane>
			<el-tab-pane v-if='switchHeadTab == "生产系统"' label="配方颗粒(颗粒)" name="配方颗粒(颗粒)">
			    <el-row>
			        <el-col :span="6">
			            <el-input style="width:300px;" placeholder="请输入关键词" v-model.trim="searchName5">
			                <i slot="prefix" class="el-input__icon el-icon-search"></i>
			                <el-button slot="append" @click="handleSearch5">搜索</el-button>
			            </el-input>
			        </el-col>
                    <el-col :span="7">
			           <el-form-item label="标准类型：" prop="standard">
                            <el-select v-model="standard"  filterable placeholder="请选择" style="width: 300px;" @change="handlechange">
                                <el-option label="国标" value="1"></el-option>
                                <el-option label='省标' value="2"></el-option>
                            </el-select>
                        </el-form-item>
			        </el-col>
<!--			        <el-button type="primary" style="float:right; margin-right: 10px" v-if="added"  @click="handleadded">新增</el-button>-->
			    </el-row>

			    <el-table
			        :data="tableData5"
			        border
			        style="margin-top:20px;"
			        ref="multipleTable"
			        header-cell-class-name="table-header"
			    >
<!--			        <el-table-column prop="checkName" sortable label="标准名称"></el-table-column>-->
			        <el-table-column prop="createTime" sortable label="添加时间"></el-table-column>
                    <el-table-column prop="standard" sortable label="标准类型"></el-table-column>
            <el-table-column prop="breedName" sortable label="物料名称"></el-table-column>
			        <el-table-column prop="basis" sortable label="附件">
			            <template slot-scope="scope">
			                <el-button
			                    type="text"
			                    @click="handlecheck(scope.$index, scope.row)"
			                >{{scope.row.basis}}</el-button>

			            </template>
			        </el-table-column>
			        <el-table-column prop="stateful" sortable label="状态"></el-table-column>
			        <el-table-column label="操作" width="150" align="center">
			            <template slot-scope="scope">
			                <el-button
			                    type="text"
			                    v-if="edit"
			                    @click="handleEdit(scope.$index, scope.row)"
			                >编辑</el-button>
			                <el-button type="text">
			                    <el-dropdown style="color: #409EFF; font-size:12px">
			                        <span class="el-dropdown-link">
			                            更多
			                        </span>
			                        <el-dropdown-menu slot="dropdown">
			                            <el-dropdown-item>
			                                <el-button
			                                    type="text"
			                                    v-if="state == scope.row.state"
			                                    style="color:black;"
			                                    v-show="disable"
			                                    @click="disabled(scope.$index, scope.row)"
			                                >禁用</el-button>
			                            </el-dropdown-item>
			                            <el-dropdown-item>
			                                <el-button
			                                    type="text"
			                                    v-show="disable"
			                                    v-if="state == scope.row.state?0:1"
			                                    @click="start(scope.$index, scope.row)"
			                                >启用</el-button>
			                            </el-dropdown-item>
			                            <el-dropdown-item>
			                                <el-button
			                                type="text"
			                                style="color:red;"
			                                v-if="del"
			                                @click="handleDelete5(scope.$index, scope.row)"
			                            >删除</el-button>
			                            </el-dropdown-item>
			                        </el-dropdown-menu>
			                    </el-dropdown>
			                </el-button>
			            </template>
			        </el-table-column>
			    </el-table>
			    <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize" :current-page.sync="currentPage5"  @current-change="handleCurrentChange5" :total="total5" style="margin-top:20px"></el-pagination>
			</el-tab-pane>
            <el-tab-pane v-if='switchHeadTab == "生产系统"' label="配方颗粒" name="配方颗粒">
                <el-row>
                    <el-col :span="7">
                        <el-input style="width:300px;" placeholder="请输入关键词" v-model.trim="searchName4">
                            <i slot="prefix" class="el-input__icon el-icon-search"></i>
                            <el-button slot="append" @click="handleSearch4">搜索</el-button>
                        </el-input>
                    </el-col>
					<el-col :span="7">
					   <el-form-item label="标准类型：" prop="standard">
					        <el-select v-model="standard"  filterable placeholder="请选择" style="width: 300px;" @change="handlechange">
					            <el-option label="国标" value="1"></el-option>
					            <el-option label='省标' value="2"></el-option>
					        </el-select>
					    </el-form-item>
					</el-col>

                  <el-button v-if="standard==2" style="float:right; margin-right: 10px" @click="download">模板下载</el-button>
                  <el-upload
                      v-if="standard==2"
                      class="upload-demo"
                      ref="upload"
                      :action="action"
                      :on-change="uploadonchange"
                      accept=".xlsx,.xls"
                      :show-file-list='false'
                      :auto-upload="false">
                    <el-button slot="trigger" size="small">导入模板</el-button>
                  </el-upload>
<!--                    <el-button type="primary" style="float:right; margin-right: 10px" v-if="added"  @click="handleadded">新增</el-button>-->
                </el-row>

                <el-table
                    :data="tableData4"
                    border
                    style="margin-top:20px;"
                    ref="multipleTable"
                    header-cell-class-name="table-header"
                >
                    <el-table-column prop="checkName" sortable label="标准名称">
                      <template slot-scope="scope">
                        <div v-if="scope.row.standard == '国标'">
                          {{scope.row.checkName}}
                        </div>
                        <div v-else>
                          {{scope.row.checkName2}}
                        </div>
                      </template>
                    </el-table-column>
                    <el-table-column prop="createTime" sortable label="添加时间"></el-table-column>
                    <el-table-column prop="standard" sortable label="标准类型"></el-table-column>
                  <el-table-column prop="breedName" sortable label="物料名称"></el-table-column>
                  <el-table-column prop="inventoryType" sortable label="产品大类"></el-table-column>
                    <el-table-column prop="basis" sortable label="附件">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                @click="handlecheck(scope.$index, scope.row)"
                            >{{scope.row.basis}}</el-button>
                        </template>
                    </el-table-column>
                    <el-table-column prop="stateful" sortable label="状态"></el-table-column>
                    <el-table-column label="操作" width="150" align="center">
                        <template slot-scope="scope">
                            <el-button
                                type="text"
                                v-if="edit"
                                @click="handleEdit(scope.$index, scope.row)"
                            >编辑</el-button>
                            <el-button type="text">
                                <el-dropdown style="color: #409EFF; font-size:12px">
                                    <span class="el-dropdown-link">
                                        更多
                                    </span>
                                    <el-dropdown-menu slot="dropdown">
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                v-if="state == scope.row.state"
                                                style="color:black;"
                                                v-show="disable"
                                                @click="disabled(scope.$index, scope.row)"
                                            >禁用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                                type="text"
                                                v-show="disable"
                                                v-if="state == scope.row.state?0:1"
                                                @click="start(scope.$index, scope.row)"
                                            >启用</el-button>
                                        </el-dropdown-item>
                                        <el-dropdown-item>
                                            <el-button
                                            type="text"
                                            style="color:red;"
                                            v-if="del"
                                            @click="handleDelete4(scope.$index, scope.row)"
                                        >删除</el-button>
                                        </el-dropdown-item>
                                    </el-dropdown-menu>
                                </el-dropdown>
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination layout="total, prev, pager, next, jumper" :page-size="pagesize" :current-page.sync="currentPage4"  @current-change="handleCurrentChange4" :total="total4" style="margin-top:20px"></el-pagination>
            </el-tab-pane>

        </el-tabs>
        <big-img v-if="showImg" @clickit="viewImg" :imgSrc="imgSrc"></big-img>
		</el-form>
    </div>
</template>

<script>
    import BigImg from '../../../common/BigImg.vue';
    import {check_list,check_delete,check_update} from '@/request/api'
    import {check_daoru,downTemplate} from "../../../../request/api";
    import axios from "axios";
    import { mapState } from 'vuex';
    export default {
        components: { 'big-img':BigImg},
        beforeRouteLeave(to, form, next) {
        next()
    },
        data() {
            return {
                showImg:false,
　　　　　　     imgSrc: '',
                state:0,
                currentPage1:1,
                currentPage2:1,
                currentPage3:1,
                currentPage4:1,
                currentPage5:1,
				currentPage6:1,
                currentPagezy:1,
                currentPagebcp:1,
                pagesize:10,
                total1:0,
                total2:0,
                total3:0,
                total4:0,
                total5:0,
				total6:0,
                totalzy:0,
                totalbcp:0,
                searchName1: '',
                searchName2: '',
                searchName3: '',
                searchName4: '',
                searchName5: '',
				searchName6: '',
                searchNamezy: '',
                searchNamebcp: '',
                activeName: '中药材',
                tableData1: [],
                tableData2: [],
                tableData3: [],
                tableData4: [],
                tableData5: [],
				tableData6: [],
                tableDatazy:[],
                tableDatabcp:[],
                boxCode:'',
                boxCode1:'',
                added:true,
                edit:true,
                disable:true,
                del:true,
                action:'',
                standard:'1'
            };
        },
        computed:{
            ...mapState(['switchHeadTab'])
        },
        created(){
            var data = JSON.stringify(this.$store.state.jcyj)
            var a = "新增"
            var b = "编辑"
            var c = "禁用"
            var d = "删除"
            if(data.indexOf(a) != -1){
                this.added = true
            }else{
                this.added = false
            }
            if(data.indexOf(b) != -1){
                this.edit = true
            }else{
                this.edit = false
            }

            if(data.indexOf(c) != -1){
                this.disable = true
            }else{
                this.disable = false
            }
            if(data.indexOf(d) != -1){
                this.del = true
            }else{
                this.del = false
            }
        },
        mounted(){
            this.activeName = this.$store.state.type
            if(this.switchHeadTab =='中药饮片'){
                this.activeName = '中药饮片(半成品)'
                this.initbcp()
            }else{
                this.activeName = '中药材'
                this.init1()
            }
        },
        destroyed: function () {
            this.$store.commit("settype","")
        },
        methods: {
          download(){
            axios({
              method: 'GET',
              url: '/check/downTemplate',
              responseType: 'blob'
            }).then(res=>{
              // console.log(res)
              this.downloadFile(res, '数据.xls')
            }).catch(err=>{
              // console.log(err)
            })
          },
          downloadFile(res, fileName) {
            let blob = new Blob([res.data]);
            if (!fileName) {
              fileName = res.headers['content-disposition'].split('filename=').pop();
            }
            if ('msSaveOrOpenBlob' in navigator) {
              window.navigator.msSaveOrOpenBlob(blob, fileName);
            } else {
              const elink = document.createElement('a');
              elink.download = fileName;
              elink.style.display = 'none';
              elink.href = URL.createObjectURL(blob);
              document.body.appendChild(elink);
              elink.click();
              URL.revokeObjectURL(elink.href);
              document.body.removeChild(elink);
            }
          },
          uploadonchange(file) {
            let formData = new FormData();
            formData.append('file', file.raw);
            let config = {
              headers:{'Content-Type':'multipart/form-data'}
            };
            check_daoru(formData).then((res) =>{
              if (res.code == 200) {
                this.$notify({
                  title: '操作成功',
                  message: '导入成功',
                  type: 'success'
                });
                this.init()
              } else{
                this.$notify.error({
                  title: '操作失败',
                  message: '导入失败',
                  type: 'error'
                });
              }
            })
          },
            handlechange() {
                this.init3()
                this.init4()
                this.init5()
                this.init6()
                this.initzy()
                this.initbcp()
            },
            handlecheck(index,row){

                this.showImg = true;
　　　　　　    // 获取当前图片地址
　　　　　　    this.imgSrc = this.$store.state.imageUrls + row.basis;
            },
            viewImg(){
                this.showImg = false;
            },
            start(index,row){
                this.$confirm('确定启用该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    row.state = 0
					let formdata = new FormData()
					for(var a in row){
					    if(row[a] == null || row[a] == "null"){
					        row[a] = ""
					        formdata.append(a,'')
					    }else{
					        formdata.append(a,row[a])
					    }
					}
                    check_update(formdata).then(res=>{
                        this.$notify({
                            title: '操作成功',
                            message: '启用成功',
                            type: 'success'
                        });
                        this.init1()
                        this.init2()
                        this.init3()
                        this.init4()
                        this.init5()
                    })
                });
            },
            disabled(index,row){
                this.$confirm('确定禁用该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    row.state = 1
					let formdata = new FormData()
					for(var a in row){
					    if(row[a] == null || row[a] == "null"){
					        row[a] = ""
					        formdata.append(a,'')
					    }else{
					        formdata.append(a,row[a])
					    }
					}
                    check_update(formdata).then(res=>{
                        this.$notify({
                            title: '操作成功',
                            message: '禁用成功',
                            type: 'success'
                        });
                        this.init1()
                        this.init2()
                        this.init3()
                        this.init4()
                        this.init5()
                    })
                });
            },
            init1(){
                check_list({
                    page:this.currentPage1,
                    type:"中药材",
                    checkName:this.searchName1
                }).then((res)=>{
                    this.tableData1 = res.rows
                    this.total1 = res.total
                    var _this = this
                    for (let i = 0; i < this.tableData1.length; i++) {
                        if(this.tableData1[i].standard == 1){
                            this.tableData1[i].standard = "国标"
                        }else if(this.tableData1[i].standard == 2){
                            this.tableData1[i].standard = "省标"
                        }
                        if(this.tableData1[i].state == 0){
                            this.tableData1[i].stateful = "启用"
                        }else{
                            this.tableData1[i].stateful = "禁用"
                        }

                    }
                })
            },
            init2(){
                check_list({
                    page:this.currentPage2,
                    type:'辅料',
                    query:this.searchName2
                }).then((res)=>{
                    this.tableData2 = res.rows
                    this.total2 = res.total
                    for (let i = 0; i < this.tableData2.length; i++) {
                        if(this.tableData2[i].standard == 1){
                            this.tableData2[i].standard = "国标"
                        }else if(this.tableData2[i].standard == 2){
                            this.tableData2[i].standard = "省标"
                        }
                        if(this.tableData2[i].state == 0){
                            this.tableData2[i].stateful = "启用"
                        }else{
                            this.tableData2[i].stateful = "禁用"
                        }

                    }
                })
            },
            init3(){
                check_list({
					standard:this.standard,
                    page:this.currentPage3,
                    type:'提取饮片',
                    query:this.searchName3
                }).then((res)=>{
                    this.tableData3 = res.rows
                    this.total3 = res.total
                    for (let i = 0; i < this.tableData3.length; i++) {
                        if(this.tableData3[i].standard == 1){
                            this.tableData3[i].standard = "国标"
                        }else if(this.tableData3[i].standard == 2){
                            this.tableData3[i].standard = "省标"
                        }
                        if(this.tableData3[i].state == 0){
                            this.tableData3[i].stateful = "启用"
                        }else{
                            this.tableData3[i].stateful = "禁用"
                        }

                    }
                })
            },
            init4(){
                check_list({
					standard:this.standard,
                    page:this.currentPage4,
                    type:"配方颗粒",
                    query:this.searchName4
                }).then((res)=>{
                    this.tableData4 = res.rows
                    this.total4 = res.total
                    for (let i = 0; i < this.tableData4.length; i++) {
                         if(this.tableData4[i].standard == 1){
                            this.tableData4[i].standard = "国标"
                        }else if(this.tableData4[i].standard == 2){
                            this.tableData4[i].standard = "省标"
                        }
                        if(this.tableData4[i].state == 0){
                            this.tableData4[i].stateful = "启用"
                        }else{
                            this.tableData4[i].stateful = "禁用"
                        }

                    }
                })
            },
            init5(){
                check_list({
                    standard:this.standard,
                    page:this.currentPage5,
                    type:"配方颗粒(颗粒)",
                    query:this.searchName5
                }).then((res)=>{
                    this.tableData5 = res.rows
                    this.total5 = res.total
                    for (let i = 0; i < this.tableData5.length; i++) {
                        if(this.tableData5[i].standard == 1){
                            this.tableData5[i].standard = "国标"
                        }else if(this.tableData5[i].standard == 2){
                            this.tableData5[i].standard = "省标"
                        }
                        if(this.tableData5[i].state == 0){
                            this.tableData5[i].stateful = "启用"
                        }else{
                            this.tableData5[i].stateful = "禁用"
                        }

                    }
                })
            },
			init6(){
			    check_list({
					standard:this.standard,
			        page:this.currentPage6,
			        type:"配方颗粒(浸膏粉)",
			        query:this.searchName6
			    }).then((res)=>{
			        this.tableData6= res.rows
			        this.total6 = res.total
			        for (let i = 0; i < this.tableData6.length; i++) {
                        if(this.tableData6[i].standard == 1){
                            this.tableData6[i].standard = "国标"
                        }else if(this.tableData6[i].standard == 2){
                            this.tableData6[i].standard = "省标"
                        }
			            if(this.tableData6[i].state == 0){
			                this.tableData6[i].stateful = "启用"
			            }else{
			                this.tableData6[i].stateful = "禁用"
			            }

			        }
			    })
			},
            initzy(){
                check_list({
                    standard:this.standard,
                    page:this.currentPagezy,
                    type:"中药饮片",
                    query:this.searchNamezy
                }).then((res)=>{
                    this.tableDatazy= res.rows
                    this.totalzy = res.total
                    for (let i = 0; i < this.tableDatazy.length; i++) {
                        if(this.tableDatazy[i].standard == 1){
                            this.tableDatazy[i].standard = "国标"
                        }else if(this.tableDatazy[i].standard == 2){
                            this.tableDatazy[i].standard = "省标"
                        }
                        if(this.tableDatazy[i].state == 0){
                            this.tableDatazy[i].stateful = "启用"
                        }else{
                            this.tableDatazy[i].stateful = "禁用"
                        }

                    }
                })
            },

            initbcp(){
                check_list({
                    standard:this.standard,
                    page:this.currentPagebcp,
                    type:"中药饮片(半成品)",
                    query:this.searchNamebcp
                }).then((res)=>{
                    this.tableDatabcp = res.rows
                    this.totalbcp = res.total
                    for (let i = 0; i < this.tableDatabcp.length; i++) {
                        if(this.tableDatabcp[i].standard == 1){
                            this.tableDatabcp[i].standard = "国标"
                        }else if(this.tableDatabcp[i].standard == 2){
                            this.tableDatabcp[i].standard = "省标"
                        }
                        if(this.tableDatabcp[i].state == 0){
                            this.tableDatabcp[i].stateful = "启用"
                        }else{
                            this.tableDatabcp[i].stateful = "禁用"
                        }

                    }
                })
            },


            handleCurrentChange1(val){
                this.currentPage1 = val
                this.init1()
            },
            handleCurrentChange2(val){
                this.currentPage2 = val
                this.init2()
            },
            handleCurrentChange3(val){
                this.currentPage3 = val
                this.init3()
            },
            handleCurrentChange4(val){
                this.currentPage4 = val
                this.init4()
            },
            handleCurrentChange5(val){
                this.currentPage5 = val
                this.init5()
            },
			handleCurrentChange6(val){
			    this.currentPage6 = val
			    this.init6()
			},
            handleCurrentChangezy(val){
                this.currentPagezy = val
                this.initzy()
            },
            handleCurrentChangebcp(val){
                this.currentPagebcp = val
                this.initbcp()
            },
            // tabs
            handleClick({paneName}, event) {
                console.log(paneName);
                switch (paneName){
                    case '中药材':
                        this.init1()
                        break;
                    case '辅料':
                        this.init2()
                        break;
                    case '提取饮片':
                        this.init3()
                        break;
                    case '配方颗粒(浸膏粉)':
                        this.init6()
                        break;
                    case '配方颗粒(颗粒)':
                        this.init5()
                        break;
                    case '配方颗粒':
                        this.init4()
                        break;
                    case '中药饮片':
                        this.initzy()
                        break;
                    case '中药饮片(半成品)':
                        this.initbcp()
                        break;
                }
            },


            handleadded(){

                this.$router.push({
                    path:'/checkingBasis/added',
                    query:{type:this.activeName,standard:this.standard}
                })
            },
            //中药材编辑
            handleEdit(index,row){
                // console.log(this.standard)
                this.$router.push({
                    path: '/checkingBasis/edit',
                    query: {
                        id: row.id ,
                        type:this.activeName,
                        standard:this.standard,
                        arr:JSON.stringify(row)
                    }
                });
            },

            //删除
            handleDelete1(index,row){
                this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    check_delete(row.id).then((res)=>{
                        this.init1()
                        this.$notify({
                            title: '操作成功',
                            message: '删除成功',
                            type: 'success'
                        });
                    })

                });
            },
            handleDelete2(index,row){
                this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    check_delete(row.id).then((res)=>{
                        // this.tableData2.splice(row,1)
                        // this.init1()
                        this.init2()
                        // this.init3()
                        // this.init4()
                        // this.init5()
                        this.$notify({
                            title: '操作成功',
                            message: '删除成功',
                            type: 'success'
                        });
                    })

                });
            },
            handleDelete3(index,row){
                this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    check_delete(row.id).then((res)=>{
                        // this.tableData3.splice(row,1)
                        // this.init1()
                        // this.init2()
                        this.init3()
                        // this.init4()
                        // this.init5()
                        this.$notify({
                            title: '操作成功',
                            message: '删除成功',
                            type: 'success'
                        });
                    })

                });
            },
            handleDelete4(index,row){
                this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    check_delete(row.id).then((res)=>{
                        // this.tableData4.splice(row,1)
                        // this.init1()
                        // this.init2()
                        // this.init3()
                        this.init4()
                        // this.init5()
                        this.$notify({
                            title: '操作成功',
                            message: '删除成功',
                            type: 'success'
                        });
                    })

                });
            },
           handleDelete5(index,row){
                this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    check_delete(row.id).then((res)=>{
                        this.init5()
                        this.$notify({
                            title: '操作成功',
                            message: '删除成功',
                            type: 'success'
                        });
                    })

                });
            },

            handleSearch1() {
                this.currentPage1 = 1
                this.init1()
            },
            handleSearch2() {
                this.currentPage2 = 1
                this.init2()
            },
            handleSearch3() {
                this.currentPage3 = 1
                this.init3()
            },
            handleSearch4() {
                this.currentPage4 = 1
                this.init4()
            },
            handleSearch5() {
                this.currentPage5 = 1
                this.init5()
            },
			handleSearch6() {
			    this.currentPage6 = 1
			    this.init6()
			},
            handleSearchzy() {
                this.currentPagezy = 1
                this.initzy()
            },
            handleSearchbcp() {
                this.currentPagebcp = 1
                this.initbcp()
            },
        }
    }
</script>

<style scoped>
.upload-demo .el-upload--text{
    border: none;
    width: auto;
    height: auto;
    border-radius: 0;
    float: right;
    margin-right: 10px
}
.el-table{ margin-top: 20px;}
.el-pagination{
    text-align: center;
}
/* .el-row{ margin-bottom: 20px;} */
.el-pagination{
    text-align: center;
}
.el-col{
    margin-bottom:0;
}

</style>
